package com.ruoyi.system.domain.wrapper.view;

import cn.hutool.core.bean.BeanUtil;
import com.eic.framework.core.domain.BaseEntityWrapperV;
import com.ruoyi.system.domain.dao.SysRole;
import com.ruoyi.system.domain.view.SysRoleVo;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 角色信息前端实体包装
 *
 * @author 尹国春
 * @date 2022-07-14
 */
public class SysRoleWrapperV extends BaseEntityWrapperV<SysRole, SysRoleVo> {

    private static SysRoleWrapperV wrapperV=null;
    //示例代码
    //private static IDemoDeptService demoDeptService;
    private SysRoleWrapperV(){
    }

    public static SysRoleWrapperV build(){
        if(wrapperV==null){
            //示例代码
            //demoDeptService= SpringUtils.getBean(IDemoDeptService.class);
            //Assert.notNull(demoDeptService);
            wrapperV=new SysRoleWrapperV();
        }
        return wrapperV;
    }

    @Override
    public SysRoleVo entityVO(SysRole entity) {
        if(entity==null){
            return new SysRoleVo();
        }
        SysRoleVo vo = BeanUtil.copyProperties(entity,SysRoleVo.class);
        //示例代码
        //vo.setDeptName(getFieldValue(demoDeptService,entity.getDeptId(),DemoDept::getDepartName));
        return vo;
    }

    @Override
    public List<SysRoleVo> listVO(List<SysRole> list) {
        List<SysRoleVo> voList=list.stream().map(user -> BeanUtil.copyProperties(user,SysRoleVo.class)).collect(Collectors.toList());
        return voList;
    }
}